package cn.com.lms.business.organization.service;

import java.util.Optional;

import com.bnzj.core.persistence.BaseService;
import com.bnzj.core.persistence.query.QueryHelpBean;
import org.springframework.stereotype.Service;

import com.bnzj.cloud.business.core.persistence.entity.SysUser;



import cn.com.lms.business.organization.persistence.entity.BasSupplierUser;
import cn.com.lms.business.organization.persistence.repository.BasSupplierUserRepository;

@Service
public class BasSupplierUserService extends BaseService<BasSupplierUserRepository, SysUser, Long> {
    
    public static QueryHelpBean getQueryHelpBean() {
        String selectSQL = " SELECT d.id, d.account, d.cname, d.email, d.sex, d.phone, d.ename, d.dept_id,d.remarks, "
        		          + "d.password, d.full_dept_name, c.name position,d.position as position_id, d.personnel, d.enabled, d.creator, d.create_time, d.modify_by, d.modify_time, d.creator_name, d.modify_name, d.v_dept_full_name, d.type, d.link_id,b.id as supplier_id,b.name as supplier_name";
        String whereSQL = " FROM bnz_sys_user d join bnz_bas_supplier b  on d.link_id=b.id  left join bnz_sys_dictionary c on c.id=d.position where d.type=\"B\"  and d.link_id=b.id ";
        QueryHelpBean queryBean = new QueryHelpBean(selectSQL + whereSQL, "select count(1)" + whereSQL, BasSupplierUser.class);
        return queryBean;
    }
    
    public Optional<SysUser> findBasSupplierUserById(Long id) {
    	return repository.findBasSupplierUserById(id);
    }
}
